package com.design.observer;

/**
 * @author leali
 * @title: ObserverClient
 * @projectName design
 * @description: ObserverClient
 * @date 2022/1/3 20:38
 */
public class ObserverClient {
    public static void main(String[] args) {
        //定义观察目标对象
        AllyControlCenter controlCenter= new ConcreteAllyControlCenter("金庸群侠");

        //定义四个观察者对象
        Observer player1,player2,player3,player4;
        player1 = new Player("杨过");
        controlCenter.join(player1);
        player2 = new Player("令狐冲");
        controlCenter.join(player2);
        player3 = new Player("张无忌");
        controlCenter.join(player3);
        player4 = new Player("段誉");
        controlCenter.join(player4);
        //某成员遭受攻击
        player1.beAttacked(controlCenter);
    }
}
